const { post, get } = require('./utils/request.js')
App({
  onLaunch() {
    // 清除本地缓存
    wx.clearStorageSync();
    wx.setStorageSync('readyLogin', true)


    const skylineObj = wx.getSkylineInfoSync();
    const appBaseInfo = wx.getAppBaseInfo()
    const deviceInfo = wx.getDeviceInfo();
    const windowInfo = wx.getWindowInfo()
    const res = wx.getMenuButtonBoundingClientRect();
    console.log('skylineObj', JSON.stringify(skylineObj))
    console.log('appBaseInfo.SDKVersion', appBaseInfo.SDKVersion)
    console.log('appBaseInfo.version', appBaseInfo.version)
    console.log('deviceInfo.brand', deviceInfo.brand)
    console.log('deviceInfo.system', deviceInfo.system)
    console.log('deviceInfo.platform', deviceInfo.platform)
    console.log('windowInfo.statusBarHeight', windowInfo.statusBarHeight)
    console.log('res.height', res.height)
    console.log('res.top', res.top)
    // 登录
    wx.login({

      success: ({ code }) => {
        post('login/login', { code: code }, ({ token, unicode, owner }) => {
          console.log('success login set unicode', unicode)
          wx.setStorageSync('token', token)
          wx.setStorageSync('unicode', unicode)
          wx.setStorageSync('owner', owner)
        })
      }, fail({ errMsg }) {
        console.log(errMsg)
      }
    })
  },
  globalData: {
    userInfo: null,
  }
})
